package com.codeforces.gym.g100095;

import java.io.File;
import java.io.FileWriter;
import java.util.Scanner;

public class F {

	static Scanner scanner;
	static FileWriter writer;
	static int n, c, all, val, bed;
	static double bal;
	static String type;

	public static void main(String[] args) throws Exception {
		scanner = new Scanner(new File("flat.in"));
		writer = new FileWriter(new File("flat.out"));
		n = scanner.nextInt();
		c = scanner.nextInt();
		bal = bed = all = 0;
		for (int i=1;i<=n;++i) {
			val = scanner.nextInt();
			all += val;
			type = scanner.next();
			if (type.startsWith("bedroom")) {
				bed += val;
			}
			else if (type.startsWith("balcony")) {
				bal += val;
			}
		}
		writer.write(all + "\n");
		writer.write(bed + "\n");
		writer.write(String.format("%.10f", c * (all - bal / 2.0)));
		writer.close();
	}

}
